/**
 * 
 */
package zaphod.toy.ogametool.ui;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;

import zaphod.toy.ogametool.core.model.Colony;

public final class ViewerSorterExtension extends ViewerSorter
{
    @Override
    public int compare( Viewer viewer, Object e1, Object e2 )
    {
        if ( e1 instanceof Colony )
        {
            Colony c1 = (Colony) e1;
            if ( e2 instanceof Colony )
            {
                Colony c2 = (Colony) e2;
                return -c1.getValue() + c2.getValue();

            }

        }
        return super.compare( viewer, e1, e2 );
    }
}